package com.yitongmao.util;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by xiaowei on 16/6/21.
 */
public class LivingListBean implements Serializable {

    /**
     * success : true
     * list : [{"fileID":16647,"extGroupID":66,"status":1,"title":"更直接","liveID":10381,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/22/f4e4f3c6-d8fb-4715-80ab-72964c7c7926_1.jpg","直播开始日期":"2016-06-22","直播开始时间":"08:00","直播结束日期":"2016-06-23","直播结束时间":"09:00"},{"fileID":16653,"extGroupID":66,"status":1,"title":"新空云发布会","liveID":10386,"columnName":"新闻~头条","imgUrl":"http://img.newaircloud.com/xkycs/pic/201606/22/c4d76b6f-4423-45c6-be8c-73c515716dc4_2027.png"},{"fileID":16648,"extGroupID":66,"status":1,"title":"发布直播测试","liveID":10382,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/22/af8913d9-d04e-4f9a-b520-1e609bc4198d.png","直播开始日期":"2016-01-01","直播结束日期":"2016-02-01"},{"fileID":16646,"extGroupID":0,"status":1,"title":"移动直播测试下位","liveID":10380,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/22/4c1901d2-c54e-4f3a-8dac-614d2e5d7df6_1.jpg"},{"fileID":16642,"extGroupID":66,"status":1,"title":"根据","liveID":10378,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/22/bf85b9d7-a1a2-4ce3-ad60-72857dbce384_1.jpg","直播开始日期":"2016-01-01","直播开始时间":"08:15:00","直播结束日期":"2016-02-01","直播结束时间":"09:00:00"},{"fileID":16639,"extGroupID":0,"status":1,"title":"丁宁","liveID":10373,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/21/2b47f35b-196f-430f-ac31-830fdeadc6b2_1.jpg"},{"fileID":16275,"extGroupID":0,"status":0,"title":"第一品牌","liveID":10371,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/21/6aca0452-bf2c-4576-b1c4-d7cbf96ef05c_1.jpg"},{"fileID":16274,"extGroupID":0,"status":1,"title":"第五章","liveID":10370,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/21/b7b6b67a-b8a2-4de2-b986-53c3e31690f4_1.jpg"},{"fileID":16273,"extGroupID":0,"status":1,"title":"地名","liveID":10369,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/21/5f628a45-5213-43e2-954e-070666f1f3d9_1.jpg"},{"fileID":16271,"extGroupID":0,"status":1,"title":"哈明明","liveID":10368,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/21/48cecb9e-2ec4-4073-a0e7-5faa132529c6_1.jpg"},{"fileID":16270,"extGroupID":0,"status":1,"title":"对华贸易","liveID":10367,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/21/b9c8fafb-3108-46d2-9d80-27a8f3c099fa_1.jpg"},{"fileID":16265,"extGroupID":0,"status":1,"title":"我是直播6","liveID":10362,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xjdcb/pic/201606/07/18250dc0-6c0c-477a-a840-0e9682ba535c.jpeg"},{"fileID":16266,"extGroupID":0,"status":1,"title":"我是直播6","liveID":10363,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xjdcb/pic/201606/07/18250dc0-6c0c-477a-a840-0e9682ba535c.jpeg"},{"fileID":16268,"extGroupID":0,"status":1,"title":"我是直播6","liveID":10365,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xjdcb/pic/201606/07/18250dc0-6c0c-477a-a840-0e9682ba535c.jpeg"},{"fileID":16269,"extGroupID":0,"status":1,"title":"我是直播6","liveID":10366,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xjdcb/pic/201606/07/18250dc0-6c0c-477a-a840-0e9682ba535c.jpeg"},{"fileID":16591,"extGroupID":0,"status":1,"title":"我是直播6","liveID":10372,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xjdcb/pic/201606/07/18250dc0-6c0c-477a-a840-0e9682ba535c.jpeg"},{"fileID":16641,"extGroupID":0,"status":1,"title":"我是直播6","liveID":10377,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xjdcb/pic/201606/07/18250dc0-6c0c-477a-a840-0e9682ba535c.jpeg"},{"fileID":16649,"extGroupID":0,"status":1,"title":"我是直播6","liveID":10383,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xjdcb/pic/201606/07/18250dc0-6c0c-477a-a840-0e9682ba535c.jpeg"},{"fileID":16267,"extGroupID":0,"status":1,"title":"不知道","liveID":10364,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/21/4b99d95b-3ded-48cb-8285-6c2e9b12a61a_1.jpg"},{"fileID":16251,"extGroupID":0,"status":1,"title":"更","liveID":10359,"columnName":"新闻~直播","imgUrl":"http://img.newaircloud.com/xkycs/upload/201606/21/73ff3c77-53ac-43f0-a971-ad5ca9b274a0.png"}]
     */

    private boolean success;
    /**
     * fileID : 16647
     * extGroupID : 66
     * status : 1
     * title : 更直接
     * liveID : 10381
     * columnName : 新闻~直播
     * imgUrl : http://img.newaircloud.com/xkycs/upload/201606/22/f4e4f3c6-d8fb-4715-80ab-72964c7c7926_1.jpg
     * 直播开始日期 : 2016-06-22
     * 直播开始时间 : 08:00
     * 直播结束日期 : 2016-06-23
     * 直播结束时间 : 09:00
     */

    private ArrayList<ListEntity> list;

    public static LivingListBean objectFromData(String str) {

        return new Gson().fromJson(str, LivingListBean.class);
    }

    public static LivingListBean objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), LivingListBean.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<LivingListBean> arrayLivingListBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<LivingListBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<LivingListBean> arrayLivingListBeanFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<LivingListBean>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public ArrayList<ListEntity> getList() {
        return list;
    }

    public void setList(ArrayList<ListEntity> list) {
        this.list = list;
    }

    public static class ListEntity implements Serializable {
        private int fileID;
        private int extGroupID;
        private int status;
        private String title;
        private int liveID;
        private String columnName;
        private String imgUrl;
        //        private String 直播开始日期;
        private String 直播开始时间;
        //        private String 直播结束日期;
        private String 直播结束时间;
        //提醒时间
        private String alarm;
        private String playStatus;
        private String liveUser;

        public static ListEntity objectFromData(String str) {

            return new Gson().fromJson(str, ListEntity.class);
        }

        public static ListEntity objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), ListEntity.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<ListEntity> arrayListEntityFromData(String str) {

            Type listType = new TypeToken<ArrayList<ListEntity>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<ListEntity> arrayListEntityFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<ListEntity>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public int getFileID() {
            return fileID;
        }

        public void setFileID(int fileID) {
            this.fileID = fileID;
        }

        public int getExtGroupID() {
            return extGroupID;
        }

        public void setExtGroupID(int extGroupID) {
            this.extGroupID = extGroupID;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public int getLiveID() {
            return liveID;
        }

        public void setLiveID(int liveID) {
            this.liveID = liveID;
        }

        public String getColumnName() {
            return columnName;
        }

        public void setColumnName(String columnName) {
            this.columnName = columnName;
        }

        public String getImgUrl() {
            return imgUrl;
        }

        public void setImgUrl(String imgUrl) {
            this.imgUrl = imgUrl;
        }

//        public String get直播开始日期() {
//            return 直播开始日期;
//        }

//        public void set直播开始日期(String 直播开始日期) {
//            this.直播开始日期 = 直播开始日期;
//        }

        public String get直播开始时间() {
            return 直播开始时间;
        }

        public void set直播开始时间(String 直播开始时间) {
            this.直播开始时间 = 直播开始时间;
        }

//        public String get直播结束日期() {
//            return 直播结束日期;
//        }

//        public void set直播结束日期(String 直播结束日期) {
//            this.直播结束日期 = 直播结束日期;
//        }

        public String get直播结束时间() {
            return 直播结束时间;
        }

        public void set直播结束时间(String 直播结束时间) {
            this.直播结束时间 = 直播结束时间;
        }

        public String getStartTime() {
            if (!StringUtils.isBlank(get直播开始时间()) && !get直播开始时间().equals("null")) {
                return get直播开始时间() + ":00";
            } else {
                return null;
            }
        }

        public String getEndTime() {
            if (!StringUtils.isBlank(get直播结束时间()) && !get直播结束时间().equals("")) {
                return get直播结束时间() + ":00";
            } else {
                return null;
            }
        }

        public void setAlarm(String alarm) {
            this.alarm = alarm;
        }

        public String getAlarm() {
            return alarm;
        }

        public String getPlayStatus() {
            return playStatus;
        }

        public void setPlayStatus(String playStatus) {
            this.playStatus = playStatus;
        }

        public String getLiveUser() {
            return liveUser;
        }

        public void setLiveUser(String liveUser) {
            this.liveUser = liveUser;
        }

    }
}
